@echo off
echo ===================================================
echo       PandaFactor Service Stop Script
echo ===================================================
echo.

:: Set color
color 0C

echo Stopping all PandaFactor related services...

:: Stop MongoDB database service
echo [1/3] Stopping MongoDB database service...
taskkill /f /fi "WINDOWTITLE eq PandaFactor Database*" > nul 2>&1
if %ERRORLEVEL% EQU 0 (
    echo MongoDB database service stopped
) else (
    echo MongoDB database service not running or could not be stopped
)

:: Stop Web service
echo [2/3] Stopping Web service...
taskkill /f /fi "WINDOWTITLE eq PandaFactor Web Service*" > nul 2>&1
if %ERRORLEVEL% EQU 0 (
    echo Web service stopped
) else (
    echo Web service not running or could not be stopped
)

:: Stop API service
echo [3/3] Stopping API service...
taskkill /f /fi "WINDOWTITLE eq PandaFactor API Service*" > nul 2>&1
if %ERRORLEVEL% EQU 0 (
    echo API service stopped
) else (
    echo API service not running or could not be stopped
)

:: Try to stop Python processes by process name
echo Checking for remaining Python processes...
taskkill /f /im python.exe /fi "WINDOWTITLE eq *PandaFactor*" > nul 2>&1
taskkill /f /im mongod.exe /fi "WINDOWTITLE eq *PandaFactor*" > nul 2>&1

echo.
echo ===================================================
echo       All PandaFactor Services Stopped
echo ===================================================
echo.

echo Press any key to exit...
pause > nul 